﻿
using NFine.Application.SystemManage;
using NFine.Code;
using NFine.Domain.Entity.SystemManage;
using NFine.Web.Areas.SSO.Models;
using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using NFine.Code;

namespace NFine.Web.Controllers
{
    [HandlerLogin]
    public class HomeController : Controller
    {
        NFineBaseEntities db = new NFineBaseEntities();

        [HttpGet]
        public virtual ActionResult Index()
        {
            return View();
        }


        [HttpGet]
        public virtual ActionResult About()
        {
            return View();
        }

        [HttpGet]
        public ActionResult Default()
        {
            //ViewBag.RandomColor = Common.RandomColor();
            string StrSql = string.Empty;
            if (!OperatorProvider.Provider.GetCurrent().IsSystem)
            {
                StrSql += @"
                                                                 select 
                                                                            s.f_id,
                                                                            s.f_user_id,
                                                                            s.f_createtime,
                                                                            s.f_updatetime,
                                                                            s.f_enable,
                                                                            s.f_username,
                                                                            a.Sa_ServerHost,
                                                                            a.Sa_App_Name,
                                                                            u.F_RealName
                                                                from Sso_SubSystem s
                                                                left join Sso_Authtication a
                                                                on s.F_Authentication_Id = a.Sa_Id
                                                                left join Sys_User u
                                                                on s.f_user_id = u.F_Id
            ";
                StrSql += string.Format(" where  u.F_Id ='{0}' ", OperatorProvider.Provider.GetCurrent().UserId);
            }
            else
            {
                StrSql = @"
                                                                 select 
                                                                           
                                                                            a.Sa_ServerHost,
                                                                            a.Sa_App_Name
                                                                from Sso_Authtication a
                                                                where a.Sa_Enable=0
            ";

            }
            var data = db.Database.SqlQuery<SusSystemModel>(StrSql);
            return View(data);
        }


    }
}
